#define _CRT_SECURE_NO_WARNINGS 1

int BSize(struct TreeNode* root)
{
    if (root == NULL)
        return 0;
    return BSize(root->left)
        + BSize(root->right) + 1;
}

void _postorderTraversal(struct TreeNode* root, int* a, int* pi)
{
    if (root)
    {
        _postorderTraversal(root->left, a, pi);
        _postorderTraversal(root->right, a, pi);
        a[*pi] = root->val;
        ++(*pi);
    }
}
int* postorderTraversal(struct TreeNode* root, int* returnSize) {
    int* a, i;
    *returnSize = BSize(root);
    a = (int*)malloc(sizeof(int) * (*returnSize));
    i = 0;
    _postorderTraversal(root, a, &i);
    return a;
}
